home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / hash / md5.1 < prev    next >
Encoding:
Text File  |  1994-03-25  |  9.2 KB  |  338 lines  |  [TEXT/R*ch]

  1. .\" @(#)md5.1    10.1 3/25/94 08:04:09
  2. .\"
  3. .\" This man page was written by:
  4. .\"
  5. .\"     Landon Curt Noll  (chongo@toad.com)    chongo <was here> /\../\
  6. .\"
  7. .\" This man page has been placed in the public domain.  Please do not 
  8. .\" copyright this man page.
  9. .\"
  10. .\" LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH  REGARD  TO
  11. .\" THIS  SOFTWARE,  INCLUDING  ALL IMPLIED WARRANTIES OF MER-
  12. .\" CHANTABILITY AND FITNESS.  IN NO EVENT SHALL  LANDON  CURT
  13. .\" NOLL  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  14. .\" DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM  LOSS  OF
  15. .\" USE,  DATA  OR  PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  16. .\" NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR  IN
  17. .\" CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. .\"
  19. .\" See md5drvr.c for version and modification history.
  20. .\"
  21. .TH MD5 1  LOCAL
  22. .SH NAME
  23. md5 \- RSA Data Security, Inc. MD5 Message-Digest Algorithm
  24. .SH SYNOPSIS
  25. .BR md5 \ [
  26. .BR \-cdhiqtx \ ][
  27. .BR \-p prefix\ ][
  28. .BR \-P prfile\ ][
  29. .BR \-s str\ ]
  30. file\ ...
  31. .SH DESCRIPTION
  32. The
  33. .B md5
  34. utility implements the 
  35. RSA Data Security, Inc. MD5 Message-Digest Algorithm (\fIMD5\fP).
  36. It produces 128-bit MD5 Digests of files, strings or data 
  37. read on stdin.
  38. If no
  39. .B file
  40. is given, and
  41. no string is to be digested (\fB\-s\fP)
  42. then stdin will be digested.
  43. By default, a digests are printed as 40 hex characters without a leading 
  44. .IR 0x .
  45. .PP
  46. The
  47. algorithm takes as input an input message of arbitrary length and
  48. produces as output a 128-bit ``fingerprint'' or ``message digest'' of the
  49. input. 
  50. It is conjectured that it is computationally infeasible to
  51. produce two messages having the same message digest, or to produce
  52. any message having a given prespecified target message digest. The
  53. .I MD5 
  54. algorithm is intended for digital signature applications, where a
  55. large file must be ``compressed'' in a secure manner before being
  56. encrypted with a private (secret) key under a public-key cryptosystem
  57. such as RSA.
  58. .PP
  59. If a 
  60. .B str 
  61. (string) argument is given, then the digest for 
  62. .BR str ,
  63. followed by a space, followed by
  64. .B str 
  65. enclosed double quotes is written to stdout.
  66. Any
  67. .B file
  68. arguments are ignored.
  69. .PP
  70. If one or more
  71. .B file
  72. if given, a separate digest if produced for each file.
  73. By default, 
  74. .B file 
  75. digests are followed by a space and the filename.
  76. .PP
  77. If no 
  78. .B str
  79. or
  80. .B file
  81. arguments are given, then a digest of stdin is written to stdout.
  82. .PP
  83. .TP
  84. .B \-c
  85. Print C style hex digests with a leading \fI0x\fP.
  86. .TP
  87. .B \-d
  88. Compute dual digests.
  89. .sp
  90. Data is divided into two streams and digested separately.
  91. Each successive octet is assigned an index starting with 0.
  92. The even stream consists of octets with even indices.
  93. The odd stream consists of octets with odd indices.
  94. The even stream digest, followed by a space, followed by
  95. the odd stream digest is written to stdout.
  96. .TP
  97. .B \-h
  98. Print a help and usage message.
  99. .TP
  100. .B \-i
  101. Compute inode digests of files.
  102. .sp
  103. Prepend the filename and various inode information to the file data 
  104. being digested.
  105. The inode information prepended includes information
  106. such as the device (\fIst_dev\fP), 
  107. inode number (\fIst_ino\fP), 
  108. mode (\fIst_mode\fP), 
  109. link count (\fIst_nlink\fP), 
  110. uid (\fIst_uid\fP), 
  111. gid (\fIst_gid\fP), 
  112. size (\fIst_size\fP),
  113. modification time (\fIst_mtime\fP) and
  114. change time (\fIst_ctime\fP).
  115. The prepended data is padded with zeros to make it a multiple of 64
  116. bytes long.
  117. Both a
  118. .BR stat (2)
  119. and a
  120. .BR lstat (2)
  121. information are both used.
  122. .sp
  123. The \fB\-i\fP flag allows one to include various inode information in
  124. the digest.  
  125. This option is useful in detecting file tampering.
  126. For example, the following will produce different digests:
  127. .sp
  128. .in +0.5i
  129. .nf
  130. md5 \-i /tmp/chongo
  131. cp /tmp/chongo /tmp/was_here
  132. \^... misc funny business ...
  133. cp /tmp/was_here /tmp/chongo
  134. md5 \-i /tmp/chongo
  135. .fi
  136. .in -0.5i
  137. .sp
  138. Note that a \fB\-i\fP digest is portable to other systems.
  139. This is because inode information will likely change as the
  140. contents of a file are copied from machine to machine.
  141. .sp
  142. To mark a \fB\-i\fP digest as a special value, \fI.0\fP is 
  143. prepended onto the digest output.
  144. .sp
  145. One may only compute inode digests of files.
  146. Use of
  147. .B \-i
  148. disables reading from stdin.
  149. The
  150. .B \-i
  151. flag is not compatible with
  152. .BR \-s .
  153. .TP
  154. .BI \-p prefix
  155. .TP
  156. .BI \-P prfile
  157. Insert a prefix into the data to be digested.
  158. .sp
  159. By using \fB\-p\fP\fIprefix\fP, one may prepend any set of data with a
  160. string.  
  161. The digest produced is equivalent to digest that is
  162. produced with the string pretended to the data.  
  163. Thus the following two commands produce the same digest:
  164. .sp
  165. .in +0.5i
  166. .nf
  167. md5 \-p curds \-s whey
  168. md5 \-s curdswhey
  169. .fi
  170. .in -0.5i
  171. .sp
  172. By use of the \fB\-P\fP\fIprfile\fP interface, one may prepend using
  173. up to the 32k of a file.  
  174. This interface allows one to prepend using binary data.  
  175. The following produces the same digest:
  176. .sp
  177. .in +0.5i
  178. .nf
  179. md5 \-P /usr/bin/awk /bin/ls
  180. dd if=/usr/bin/awk of=/tmp/foo bs=32k count=1
  181. cat /tmp/foo /bin/ls > /tmp/ls
  182. md5 /tmp/ls
  183. .fi
  184. .in -0.5i
  185. .sp
  186. Knowledge of the original prepend data is only kept in
  187. the digest.  
  188. Thus one may use the prepend string as a ``salt'' making it intractable 
  189. for someone else to reproduce the digest of a file without knowledge 
  190. of the prepend data.
  191. .sp
  192. For sightly faster performance, use prepend data that is
  193. a multiple of 64 bytes long.  
  194. The easy way to do this is to use \fB-P\fP on a file that is at least 32k
  195. bytes in length.
  196. .sp
  197. This feature works in conjunction all modes of operation except
  198. the \fB\-t\fP and \fB\-x\fP modes.
  199. .TP
  200. .B \-q
  201. Output only digests.
  202. The filename or string will not be written to stdout.
  203. .TP
  204. .BR \-s str
  205. Digest \fIstr\fP as if it were a string.
  206. .sp
  207. The trailing NUL byte is not digested.
  208. No files are digested.
  209. The \fIstr\fP is written to stdout enclosed in double quotes.
  210. .TP
  211. .BR \-t
  212. Time the user cpu seconds needed to digest several megabytes of data.
  213. The number of megabytes,
  214. followed by the digest produced,
  215. followed by the number of user cpu seconds
  216. followed by the number of characters per user second is written to stdout.
  217. .sp
  218. On some systems with certain virtual memory characteristics,
  219. you may need to run the performance test several times, ignoring the
  220. first result.
  221. The default amount of data tested is 16 megabytes.
  222. On some systems, this amount may differ.
  223. One may change the number of megabytes processed by changing the value of
  224. TEST_MEG in the file md5drvr.c and recompiling.
  225. .TP
  226. .BR \-v
  227. Print the version.
  228. .TP
  229. .BR \-x
  230. Perform an extended standard SHS test suite.
  231. .sp
  232. The test suite will first look in the current directory for
  233. .IR file1 .
  234. If it is not found, it will look in ${DESTDIR} (usually 
  235. .IR /usr/local/lib/md5 ).
  236. It is assumes that 
  237. .I file2 
  238. is in the same location as 
  239. .sp
  240. The standard test suite been extended.  
  241. The initial string now says:
  242. .sp
  243. .in +0.5i
  244. .nf
  245. md5 test suite results
  246. .fi
  247. .in -0.5i
  248. .sp
  249. instead of:
  250. .sp
  251. .in +0.5i
  252. .nf
  253. SHA test suite results
  254. .fi
  255. .in -0.5i
  256. .sp
  257. to reflect the utility name instead of the algorithm implemented.
  258. This also helps distinguish this version from much older 
  259. versions which did not have the 
  260. .B -v 
  261. flag.
  262. Also the original test file
  263. .I foo
  264. which contained the string  "\fIabc\fP" (with no newline) was renamed 
  265. .IR file1 .
  266. .SH "SEE ALSO"
  267. .BR shs (1),
  268. .BR stat (2),
  269. .BR lstat (2)
  270. .SH FILES
  271. .nf
  272. \^./file1            default test file location
  273. \^./file2            default test file location
  274. ${DESTDIR}/file1    alternate test file location
  275. ${DESTDIR}/file2    alternate test file location
  276. .fi
  277. .sp
  278. The typical value of ${DESTDIR} is \fI/usr/local/lib/md5\fP,
  279. or \fI/usr/local/lib\fP.
  280. .SH AUTHOR
  281. .nf
  282. Much of this code was written, re-written or modified by:
  283.  
  284.     Landon Curt Noll    (chongo@toad.com)  /\\../\\
  285.  
  286. Part of this code code is based on code by Peter C. Gutmann.
  287. .fi
  288. .SH NOTICE
  289. LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  290. INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 
  291. IN NO EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  292. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  293. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  294. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  295. PERFORMANCE OF THIS SOFTWARE.
  296. .PP
  297. Parts of this code are:
  298. .PP
  299. Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.
  300. .PP
  301. License to copy and use this software is granted provided that
  302. it is identified as the "RSA Data Security, Inc. MD5 Message-
  303. Digest Algorithm" in all material mentioning or referencing this
  304. software or this function.
  305. .PP
  306. License is also granted to make and use derivative works
  307. provided that such works are identified as "derived from the RSA
  308. Data Security, Inc. MD5 Message-Digest Algorithm" in all
  309. material mentioning or referencing the derived work.
  310. .PP
  311. RSA Data Security, Inc. makes no representations concerning
  312. either the merchantability of this software or the suitability
  313. of this software for any particular purpose.  It is provided "as
  314. is" without express or implied warranty of any kind.
  315. .PP
  316. These notices must be retained in any copies of any part of this
  317. documentation and/or software.
  318. .SH BUGS
  319. The command:
  320. .sp
  321. .in +0.5i
  322. .nf
  323. md5 -s '/\\"O/\\'
  324. .fi
  325. .in -0.5i
  326. .sp
  327. writes to stdout, the following line:
  328. .sp
  329. .in +0.5i
  330. .nf
  331. ae8b1f8db9eaa95693164bd224291da0 "/\\"O/\\"
  332. .fi
  333. .in -0.5i
  334. .sp
  335. The string written in double quotes by
  336. .B \-s
  337. may not be a valid string according to C or shell syntax.
  338.